package cn.com.cpic.insurance.rulecheck.core.test;

import java.util.Set;

import cn.com.cpic.insurance.rulecheck.core.BomContext;
import cn.com.cpic.insurance.rulecheck.core.Context;
import cn.com.cpic.insurance.rulecheck.core.ModifiableMap;
import cn.com.cpic.insurance.rulecheck.core.ModifiableSet;
import cn.com.cpic.insurance.rulecheck.core.SimpleBomContext;
import cn.com.cpic.insurance.rulecheck.core.SimpleContext;
import cn.com.cpic.insurance.rulecheck.core.SimpleModifiableMap;
import cn.com.cpic.insurance.rulecheck.core.SimpleModifiableSet;
import cn.com.cpic.insurance.rulecheck.core.Tokenable;
import cn.com.cpic.insurance.rulecheck.core.condition.Condition;
import cn.com.cpic.insurance.rulecheck.core.condition.ConditionGroup;
import cn.com.cpic.insurance.rulecheck.core.condition.ConditionSwitch;
import cn.com.cpic.insurance.rulecheck.core.condition.Conditions;
import cn.com.cpic.insurance.rulecheck.core.condition.SimpleConditionGroup;
import cn.com.cpic.insurance.rulecheck.core.condition.SimpleConditionSwitch;
import cn.com.cpic.insurance.rulecheck.core.condition.SimpleConditions;
import cn.com.cpic.insurance.rulecheck.core.parameter.ParameterDictionary;
import cn.com.cpic.insurance.rulecheck.core.parameter.SimpleParameterDictionary;

/**
 * 
 * 
 * @author 代波
 * @since 2011-8-13
 */
public abstract class ConditionTestUtils {
	public static Condition createCondition(final String token, final boolean result) {
		return new Condition() {
			private static final long serialVersionUID = 3175626686679440001L;

			public String getToken() {
				return token;
			}

			public Boolean operate(Context context) {
				return result;
			}
		};
	}

	public static ConditionGroup createConditionGroup(String token) {
		return new SimpleConditionGroup(token);
	}

	public static ConditionGroup createConditionGroup(String token, Set<Condition> set) {
		return new SimpleConditionGroup(token, set);
	}

	public static ConditionSwitch createConditionSwitch(String token) {
		return new SimpleConditionSwitch(token);
	}

	public static ConditionSwitch createConditionSwitch(String token, Set<Condition> set) {
		return new SimpleConditionSwitch(token, set);
	}

	public static Conditions createConditions() {
		return new SimpleConditions();
	}

	public static Conditions createConditions(Set<Condition> cSet, Set<ConditionSwitch> csSet) {
		return new SimpleConditions(cSet, csSet);
	}

	public static <T> ModifiableSet<T> createModifiableSet(Class<T> clazz) {
		return new SimpleModifiableSet<T>();
	}

	public static <T> ModifiableSet<T> createModifiableSet(Set<T> set) {
		return new SimpleModifiableSet<T>(set);
	}

	public static <K, V extends Tokenable<K>> ModifiableMap<K, V> createModifiableMap(Class<V> clazz) {
		return new SimpleModifiableMap<K, V>();
	}

	public static <K, V extends Tokenable<K>> ModifiableMap<K, V> createModifiableMap(Set<V> set) {
		return new SimpleModifiableMap<K, V>(set);
	}

	public static Context createContext(BomContext bomContext) {
		return new SimpleContext(bomContext);
	}

	public static BomContext createBOMContext() {
		return new SimpleBomContext();
	}

	public static ParameterDictionary createParameterDictionary() {
		return new SimpleParameterDictionary();
	}
}
